package controller.states;

import controller.Controller;
import controller.Controller.StateType;
import controller.IState;

/*
 * 
 * GamePlayState class
 * 
 * State used during active game play.
 * Evaluates user input to dictate player movement or pausing.
 * 
 */

public class GameplayState implements IState {

	private static final int W = 87;// get the keycodes
	private static final int A = 65;
	private static final int S = 83;
	private static final int D = 68;
	private static final int ENTER = 10;

	Controller controller;
	public StateType state;

	/**
	 * GameplayState
	 * 
	 * creates the GameplayState based upon the controller that was passed into it
	 * 
	 * @param c
	 */
	public GameplayState(Controller c) {
		controller = c;
		state = StateType.GAMEPLAY;
	}

	/* (non-Javadoc)
	 * @see controller.IState#getState()
	 */
	@Override
	public StateType getState() {
		return state;
	}

	/* (non-Javadoc)
	 * @see controller.IState#handleKeyPressed(int)
	 */
	@Override
	public void handleKeyPressed(int keyCode) {
		switch (keyCode) {
		case W:
			controller.moveJump();
			break;

		case A:
			controller.moveLeft();
			break;

		case S:
			break;

		case D:
			controller.moveRight();
			break;

		case ENTER:
			controller.togglePause();
			break;

		default:
			break;
		}
	}

	/* (non-Javadoc)
	 * @see controller.IState#handleKeyReleased(int)
	 */
	@Override
	public void handleKeyReleased(int keyCode) {
		switch (keyCode) {
		case W:
			break;

		case A:
			controller.moveStop();
			break;

		case S:
			break;

		case D:
			controller.moveStop();
			break;

		default:
			break;
		}
	}

}
